<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
	<div class="wrapper wrapper-content ">
		<div class="row">
			<div class="col-sm-12">
				<div class="ibox float-e-margins">
					<div class="ibox-content">
						<form class="form-horizontal m-t" id="signupForm">
							<div class="form-group">	
								<label class="col-sm-3 control-label">标题：</label>
								<div class="col-sm-8">
									<input id="title" name="title" class="form-control" type="text">
								</div>
							</div>
														<div class="form-group">	
								<label class="col-sm-3 control-label">名称：</label>
								<div class="col-sm-8">
									<input id="name" name="name" class="form-control" type="text">
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">作者：</label>
								<div class="col-sm-8">
									<input id="author" name="author" class="form-control" type="text">
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">跳转地址：</label>
								<div class="col-sm-8">
									<input id="link" name="link" class="form-control" type="text">
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">是否启用：</label>
								<div class="col-sm-8">
									<select class="form-control" id="enable" name="enable">
										<option value="1">是</option>
										<option value="0">否</option>
									</select>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">置顶：</label>
								<div class="col-sm-8">
									<select class="form-control" id="isTop" name="isTop">
										<option value="0">否</option>
										<option value="1">是</option>
									</select>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">公告类型：</label>
								<div class="col-sm-8">
									<select class="form-control" id="type" name="type">
										<option value="1">首页公告</option>
										<option value="2">创作者通知</option>
									</select>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">摘要文本：</label>
								<div class="col-sm-8">
									<input id="abstractText" name="abstractText" class="form-control" type="text">
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">内容：</label>
								<div class="col-sm-8">
									<input id="content" name="content" class="form-control" type="hidden">
									<div id="summernote" name="summernote" class="form-control"></div>
								</div>
							</div>


																					<div class="form-group">
								<div class="col-sm-8 col-sm-offset-3">
									<button type="submit" class="btn btn-primary">提交</button>
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
	</div>
	</div>
	<div th:include="include::footer"></div>
	<script type="text/javascript" src="/js/appjs/wallpaper/bzNotice/add.js" th:src="@{/js/appjs/wallpaper/bzNotice/add.js}">
	</script>

<script>

	$(document).ready(function() {

		$('#summernote').summernote({
			height: 300,   // 定义编辑框高度
			minHeight: 300,  // 定义编辑框最低的高度
			maxHeight: null,  // 定义编辑框最高德高度
			placeholder : '请输入文章内容', // 提示
			lang:'zh-CN',
			callbacks: {
				onChange: function (contents, $edittable) {
					console.log('监听到了');
				},
				onImageUpload: function (files) {
					sendFile(this, files[0]);
				}
			}
		});

		$('#summernote').summernote('code', $("#content").val())
		console.log($('#summernote'));


		function sendFile(val, files) {
			let data = new FormData();
			data.append("file", files);
			$.ajax({
				data: data,
				dataType: 'json',
				type: "POST",
				url: ctxPath +"common/sysFile/upload/domain",
				cache: false,
				contentType: false,
				processData: false,
				responseType: "json",
				success: function (data) {
					console.log(data.fileName)
					$('#summernote').summernote('editor.insertImage',data.fileName);
				},
				error: function (XMLHttpRequest, textStatus, errorThrown) {
					alert(XMLHttpRequest.status);
					alert(XMLHttpRequest.readyState);
					alert(textStatus);
				}
			});
		}
	})
</script>
</body>
</html>
